<%@ page contentType="text/html;charset=UTF-8" %>

<!DOCTYPE html>
<html>
<head>
	<title>数据分类</title>
	 <%@ include file="/common/meta.jsp" %>
	<%@ include file="/common/import.jsp" %>
	<script type="text/javascript" src="${ctx}/js/zbxtools.js"></script>
	<script type="text/javascript">
		var inputForm = '#inputForm';
		$(function(){
			$(inputForm).form({
			    onSubmit:function(){		    	
			    	return $(this).form('validate');
			    },
			    success:function(data){
			    	var result = jQuery.parseJSON(data);
			    	if(result.flag=='T'){
			    		$.messager.alert('提交结果', '操作成功', 'info',function(){
			    			parent.colseAdd();
			    			parent.reload();
			    		});	
			    	}else {
			    		$.messager.alert('提交结果', '操作失败', 'error');
			    	}        
			    }
			});
		}) ;
		ZBXTools.initRadio("sortDisable","${item.sortDisable}");
		ZBXTools.initRadio("sortStatistics","${item.sortStatistics}");
	</script>

<body>	

<div id="tip"></div>
	<form id="inputForm" name="inputForm" method="post" action="${ctx }/info/core/save.action">
		<input type="hidden" name="formToken" id="formToken" value="${formToken}"/>
		<input type="hidden" name="sortId" id="sortId" value="${item.sortId}"/>
		<input type="hidden" name="infoTableName" id="infoTableName" value="${item.infoTableName}"/>
		<input type="hidden" name="sortStatus" id="sortStatus" value="${item.sortStatus}"/>
		<table class="datagrid-body" >
			<tr>
				<td class="datagrid-header">分类编号<font color="red">*</font></td>
				<td>
					<input id="sortCode" name="sortCode"  value="${item.sortCode}"
					<c:if test="${!empty item.sortCode}"> readonly="readonly" </c:if> 
					class="easyui-validatebox" data-options="required:true" style="width:220px;" 
					missingMessage="分类编号，用字母组合"/>
				</td>
			</tr>
			<tr >
				<td class="datagrid-header">表前缀<font color="red">*</font></td>
				<td>
					<input name="tablePrefix" id="tablePrefix" onchange="setInfoTableName()" value="${item.tablePrefix}"
					<c:if test="${!empty item.tablePrefix}"> readonly="readonly" </c:if> 
					class="easyui-validatebox" style="width:220px;" data-options="required:true"
					missingMessage="请输入表前缀"  />				
				</td>
			</tr>
			<tr >
				<td class="datagrid-header">分类名称<font color="red">*</font></td>
				<td>
					<input name="sortName"  id="sortName" value="${item.sortName}"
					class="easyui-validatebox" style="width:220px;" data-options="required:true"
					missingMessage="请输入分类名称"  />				
				</td>
			</tr>
			
			<tr >
				<td class="datagrid-header">对象名<font color="red">*</font></td>
				<td>
					<input name="objName"  id="objName" value="${item.objName}" />				
				</td>
			</tr>
			<tr>
					<td class="datagrid-header">是否需要审核</td>
					<td>
					<input type="radio" name="sortDisable" id="sortDisable_1" value="1" />是
					<input type="radio" name="sortDisable" checked="checked" id="sortDisable_0" value="0" />否
					</td>
				</tr>
				<tr>
					<td class="datagrid-header">是否加入统计</td>
					<td>
					<input type="radio" name="sortStatistics" id="sortStatistics_1" value="1" checked="checked" />是
					<input type="radio" name="sortStatistics" id="sortStatistics_0" value="0" />否
					</td>
				</tr>
				<c:if test="${empty item.sortId }">
				<tr>
					<td class="datagrid-header">是否为主表</td>
					<td>
					<input type="radio" name="mainTab" value="1" />是
					<input type="radio" name="mainTab" checked="checked"  value="0" />否
					</td>
				</tr>
				</c:if>
			<tr>
				<td class="datagrid-header"></td>
				<td>	
					<a href="#" class="easyui-linkbutton" iconCls="icon-save" onclick="$('#inputForm').submit();">提交</a>	
					<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="parent.colseAdd();"; >取消</a>	
				</td>
			</tr>
		</table>
	</form>
</body>
<script>
function setInfoTableName(){
	var sysCode = $("#tablePrefix").val();
	var sortCode = $("#sortCode").val();
	var tableName = sysCode+"_"+sortCode;
	$("#infoTableName").val(tableName);
	$("#objName").val(sysCode+tranformStr1(sortCode));
}
//字符串转成驼峰的方法
function transformStr3(str){
    var re=/_(\w)/g;
    return str.replace(re,function ($0,$1){
        return $1.toUpperCase();
    });
}
//首字母大写
function tranformStr1(str){
    var strArr=transformStr3(str);
    strArr=strArr.charAt(0).toUpperCase()+strArr.substring(1);
    return strArr;
}
</script>
</html>